import 'package:flutter/material.dart';
import '../demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Text(this.title),
            actions: <Widget>[
              IconSource("State","15"),
            ],
          ),
          body: StateDemo(),
        )
    );
  }
}
class StateDemo extends StatefulWidget {
  @override
  _StateDemoState createState() => _StateDemoState();
}

class _StateDemoState extends State<StateDemo> {
  int count=0;
   _increseCount(){
     setState(() {
       count+=1;
     });
   }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
    body: Container(
      child: Center(
        child: CounterDemo(_increseCount, count),
      ),
    ),
      floatingActionButton: FloatingActionButton(
        onPressed: _increseCount,
        child: Icon(Icons.add),
      ),
    );
  }
}
class CounterDemo extends StatelessWidget {
  final VoidCallback increseCount;
  final int count;
  CounterDemo(this.increseCount,this.count);
  @override
  Widget build(BuildContext context) {
    return Center(
      child: ActionChip(label: Text("$count"), onPressed: increseCount),
    );
  }
}



